<?php



namespace App\Http\Requests\Backend;

use App\Http\Requests\ApiV2\BaseRequest;
use Illuminate\Support\Facades\Auth;

class CompanyMenuRequest extends BaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => 'required',
        ];
    }

    public function messages()
    {
        return [
            'name.required' => __('请输入菜单名'),
            'parent_id.required' => __('请输入父节点'),
            'sort.required' => __('请输入排序'),
            'url.required' => __('请输入url'),
            'icon.required' => __('请输入icon'),
            'permission.required' => __('请输入权限名'),
            'is_super.required' => __('请输入权限名'),
        ];
    }

    public function filldata()
    {
        return [
            'company_id'=>Auth::user()->login_company_id,
            'name' => $this->input('name'),
            'parent_id' => (int)$this->input('parent_id', 0),
            'sort'=>(int)$this->input('sort',0),
            'url'=>(string)$this->input('url',''),
            'icon'=>$this->input('icon',''),
            'permission'=>$this->input('permission',''),
            'is_super'=>$this->input('is_super',0),
        ];
    }
}
